package com.canbot.u05.activity.agenda.bean

import com.canbot.u05.activity.agenda.calendar.getWeekToDate
import java.io.Serializable

/**
 * @author yinxiaowei
 * @date 2019/5/31
 */
class DateBean : Serializable, Comparable<DateBean> {
    override fun compareTo(other: DateBean): Int {
        return if (this.week != -1) {
            if (other.week != -1) {
                this.week.compareTo(other.week)
            } else {
                getWeekToDate(this.week).compareTo(other.date)
            }
        } else {
            if (other.week != -1) {
                this.date.compareTo(getWeekToDate(other.week))
            } else {
                this.date.compareTo(other.date)
            }
        }
    }

    var isRepeat = false
    var week: Int = -1

    /**
     * 日期：（年 - 月- 日）
     */
    var date: String = ""

    override fun toString(): String {
        return "DateBean(isRepeat=$isRepeat, week=$week, date=$date)"
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as DateBean

        if (isRepeat != other.isRepeat) {
            return false
        }
        if (week != other.week) {
            return false
        }
        if (date != other.date) {
            return false
        }
        return true
    }

    override fun hashCode(): Int {
        var result = isRepeat.hashCode()
        result = 31 * result + week
        result = 31 * result + date.hashCode()
        return result
    }

}